package com.duoec.magichour.core.web.freemarker.dto;

/**
 * Created by ycoe on 16/5/18.
 */
public abstract class SortedData<T> implements Comparable<SortedData<T>> {

    /**
     * 内容，可以是文件或字符串
     */
    protected T data;

    /**
     * 排序，越小越前
     */
    private int sort;

    /**
     * 最后修改时间，用于判断是否有变更
     */
    private long lastModify;

    private String key;

    public SortedData(T data, int sort, long fileLastModified) {
        this.data = data;
        this.sort = sort;
        this.lastModify = fileLastModified;
    }

    @Override
    public int compareTo(SortedData<T> o) { //NOSONAR
        return this.sort - o.sort;
    }

    @Override
    public abstract String toString();

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public long getLastModify() {
        return lastModify;
    }

    public void setLastModify(long lastModify) {
        this.lastModify = lastModify;
    }
}
